# -*- coding: utf-8 -*-
from datetime import timedelta

# from jms.ods.oms.yl_oms_oms_waybill import jms_ods__yl_oms_oms_waybill
# from jms.ods.oms.yl_oms_oms_order import jms_ods__yl_oms_oms_order
# from jms.ods.tab.tab_barscan_other import jms_ods__tab_barscan_other
# from jms.ods.tab.tab_barscan_taking import jms_ods__tab_barscan_taking
# from jms.ods.tab.tab_barscan_warehousing import jms_ods__tab_barscan_warehousing
# from jms.ods.tab.tab_barscan_sitesend import jms_ods__tab_barscan_sitesend
# from jms.ods.tab.tab_barscan_sitearrival import jms_ods__tab_barscan_sitearrival
# from jms.ods.tab.tab_barscan_unloading import jms_ods__tab_barscan_unloading
# from jms.ods.tab.tab_barscan_bagging import jms_ods__tab_barscan_bagging
# from jms.ods.tab.tab_barscan_centersend import jms_ods__tab_barscan_centersend
# from jms.ods.tab.tab_barscan_centerarrival import jms_ods__tab_barscan_centerarrival
# from jms.ods.tab.tab_barscan_loading import jms_ods__tab_barscan_loading
# from jms.ods.tab.tab_barscan_deliver import jms_ods__tab_barscan_deliver
# from jms.ods.tab.tab_barscan_sign import jms_ods__tab_barscan_sign
# from jms.ods.tab.tab_barscan_collect_back import jms_ods__tab_barscan_collect_back
# from jms.ods.tab.tab_barscan_difficult import jms_ods__tab_barscan_difficult
# from jms.ods.tab.tab_reback_transfer_express_di import jms_ods__tab_reback_transfer_express_di
# from jms.ods.tab.tab_end_piece_di import jms_ods__tab_end_piece_di
# from jms.ods.oms.yl_oms_interceptorpiece import jms_ods__yl_oms_interceptorpiece_di
# from jms.dwd.tms.dwd_tmsnew_shipment_stop_union_base_dt import jms_dwd__dwd_tmsnew_shipment_stop_union_base_dt
# from jms.dwd.tms.dwd_tmsnew_shipment_union_base_dt import jms_dwd__dwd_tmsnew_shipment_union_base_dt
from utils.operators.cluster_for_spark_sql_hook_test_for_airflow_bug_operator import SparkSqlOperator

jms_dwd__test_barscan_operations_hist_dt = SparkSqlOperator(
    task_id='jms_dwd__test_barscan_operations_hist_dt',
    task_concurrency=1,
    pool_slots=9,
    master='yarn',
    name='jms_dwd__test_barscan_operations_hist_dt_{{ execution_date | date_add(1) | cst_ds }}',
    sql='jms_route_test/dm/dwd_wide_barscan_operations_hist_dt/execute.sql',
    driver_memory='20G',
    driver_cores=8,
    email=['rongguangfan@jtexpress.com','yl_bigdata@yl-scm.com'],
    executor_cores=10,
    retries=1,
    executor_memory='10G',
    priority_weight=5,
    num_executors=150,  # spark.dynamicAllocation.enabled 为 True 时，num_executors 表示最少 Executor 数
    conf={'spark.dynamicAllocation.enabled': 'true',  # 动态资源开启
          'spark.shuffle.service.enabled': 'true',  # 动态资源 Shuffle 服务开启
          'spark.dynamicAllocation.maxExecutors': 240,  # 动态资源最大扩容 Executor 数
          'spark.dynamicAllocation.cachedExecutorIdleTimeout': 180,  # 动态资源自动释放闲置 Executor 的超时时间(s)
          'spark.sql.sources.partitionOverwriteMode': 'dynamic',  # 允许删改已存在的分区
          'spark.executor.memoryOverhead': '6G',  # 堆外内存
          'spark.sql.shuffle.partitions': 6000,
          'spark.default.paralleism': 6000,
          'spark.hadoop.hive.exec.dynamic.partition.mode': 'true',
          'spark.sql.autoBroadcastJoinThreshold': 2147483648,
          },
    # hiveconf={'hive.exec.dynamic.partition': 'true',  # 动态分区
    #           'hive.exec.dynamic.partition.mode': 'nonstrict',
    #           'hive.exec.max.dynamic.partitions': 90,  # 每天生成 60 个分区
    #           'hive.exec.max.dynamic.partitions.pernode': 90,  # 每天生成 60 个分区
    #           },
    yarn_queue='warehouse',
    #execution_timeout=timedelta(hours=2)
    #excel平均时长:16分31秒
    execution_timeout = timedelta(minutes=90),
)

# jms_dwd__test_barscan_operations_hist_dt << [
#     # jms_ods__tab_barscan_taking,
#     # jms_ods__tab_barscan_warehousing,
#     # jms_ods__tab_barscan_sitesend,
#     # jms_ods__tab_barscan_sitearrival,
#     # jms_ods__tab_barscan_unloading,
#     # jms_ods__tab_barscan_bagging,
#     # jms_ods__tab_barscan_centersend,
#     # jms_ods__tab_barscan_centerarrival,
#     # jms_ods__tab_barscan_loading,
#     # jms_ods__tab_barscan_deliver,
#     # jms_ods__tab_barscan_sign,
#     # jms_ods__tab_barscan_other,
#     # jms_ods__tab_barscan_collect_back,
#     # jms_ods__yl_oms_oms_waybill,
#     # jms_ods__yl_oms_oms_order,
#     # jms_dwd__dwd_tmsnew_shipment_stop_union_base_dt,
#     # jms_dwd__dwd_tmsnew_shipment_union_base_dt,
#     # jms_ods__tab_barscan_difficult,
#     # jms_ods__tab_reback_transfer_express_di,
#     # jms_ods__tab_end_piece_di,
#     # jms_ods__yl_oms_interceptorpiece_di
# ]
